package uaiContacts.model;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Droog
 */
@Entity
@Table(name = "tb_telefone", catalog = "sistema_ipi", schema = "public")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Telefone.findAll", query = "SELECT t FROM Telefone t"),
    @NamedQuery(name = "Telefone.findByIdTelefone", query = "SELECT t FROM Telefone t WHERE t.idTelefone = :idTelefone"),
    @NamedQuery(name = "Telefone.findByNumTelefone", query = "SELECT t FROM Telefone t WHERE t.numTelefone = :numTelefone"),
    @NamedQuery(name = "Telefone.findByDdd", query = "SELECT t FROM Telefone t WHERE t.ddd = :ddd"),
    @NamedQuery(name = "Telefone.findByDatCadastro", query = "SELECT t FROM Telefone t WHERE t.datCadastro = :datCadastro")})
public class Telefone implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_telefone", nullable = false)
    private Integer idTelefone;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "num_telefone", nullable = false, length = 15)
    private String numTelefone;
    @Size(max = 3)
    @Column(length = 3)
    private String ddd;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dat_cadastro", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date datCadastro;
    @ManyToMany(mappedBy = "telefoneList")
    private List<DadosIgreja> dadosIgrejaList;
    @ManyToMany(mappedBy = "telefoneList")
    private List<Membro> membroList;
    @ManyToMany(mappedBy = "telefoneList")
    private List<Contato> contatoList;
    @JoinColumn(name = "id_tipo_telefone", referencedColumnName = "id_tipo_telefone", nullable = false)
    @ManyToOne(optional = false)
    private TipoTelefone idTipoTelefone;

    public Telefone() {
    }

    public Telefone(Integer idTelefone) {
        this.idTelefone = idTelefone;
    }

    public Telefone(Integer idTelefone, String numTelefone, Date datCadastro) {
        this.idTelefone = idTelefone;
        this.numTelefone = numTelefone;
        this.datCadastro = datCadastro;
    }

    public Integer getIdTelefone() {
        return idTelefone;
    }

    public void setIdTelefone(Integer idTelefone) {
        this.idTelefone = idTelefone;
    }

    public String getNumTelefone() {
        return numTelefone;
    }

    public void setNumTelefone(String numTelefone) {
        this.numTelefone = numTelefone;
    }

    public String getDdd() {
        return ddd;
    }

    public void setDdd(String ddd) {
        this.ddd = ddd;
    }

    public Date getDatCadastro() {
        return datCadastro;
    }

    public void setDatCadastro(Date datCadastro) {
        this.datCadastro = datCadastro;
    }

    @XmlTransient
    public List<DadosIgreja> getDadosIgrejaList() {
        return dadosIgrejaList;
    }

    public void setDadosIgrejaList(List<DadosIgreja> dadosIgrejaList) {
        this.dadosIgrejaList = dadosIgrejaList;
    }

    @XmlTransient
    public List<Membro> getMembroList() {
        return membroList;
    }

    public void setMembroList(List<Membro> membroList) {
        this.membroList = membroList;
    }

    @XmlTransient
    public List<Contato> getContatoList() {
        return contatoList;
    }

    public void setContatoList(List<Contato> contatoList) {
        this.contatoList = contatoList;
    }

    public TipoTelefone getIdTipoTelefone() {
        return idTipoTelefone;
    }

    public void setIdTipoTelefone(TipoTelefone idTipoTelefone) {
        this.idTipoTelefone = idTipoTelefone;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTelefone != null ? idTelefone.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Telefone)) {
            return false;
        }
        Telefone other = (Telefone) object;
        if ((this.idTelefone == null && other.idTelefone != null) || (this.idTelefone != null && !this.idTelefone.equals(other.idTelefone))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Telefone[ idTelefone=" + idTelefone + " ]";
    }
    
}